package com.jnsw.testkotlin;

import android.animation.AnimatorInflater;
import android.animation.AnimatorSet;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class AnimActivity extends Activity implements View.OnClickListener {
    ImageView anim_img;
    Animation animation;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_anim);
        anim_img = (ImageView) findViewById(R.id.anim_img);
        String abc = null;
        "".equals(abc);




    }

    @Override
    public void onClick(View v) {

        switch (v.getId()) {
            case R.id.xz:
                animation = AnimationUtils.loadAnimation(this, R.anim.rotate);
                animation.setDuration(3000);

                anim_img.startAnimation(animation);
                break;
            case R.id.py:
                animation = AnimationUtils.loadAnimation(this, R.anim.translate);
                animation.setDuration(3000);
                anim_img.startAnimation(animation);
                break;
            case R.id.jy:
                animation = AnimationUtils.loadAnimation(this, R.anim.alpha);
                animation.setDuration(300);
                anim_img.startAnimation(animation);
                break;
            case R.id.sf:
                animation = AnimationUtils.loadAnimation(this, R.anim.sacle);
                animation.setDuration(3000);
                anim_img.startAnimation(animation);
                break;
            case R.id.py2:
                Log.d("py-------------","平移");
                System.out.println("pingyi 22222222222222222222");
                AnimatorSet animation =  (AnimatorSet) AnimatorInflater.loadAnimator(AnimActivity.this,
                    R.animator.pingyi);
                animation.setTarget(anim_img);
                if (!animation.isRunning()){

                    animation.start();
                }else {
                    animation.cancel();

                }
                break;

        }
    }
}
